<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
        <meta charset="UTF-8">
        <title>设备安检记录</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="__HOME_CSS__/font.css">
        <link rel="stylesheet" href="__HOME_CSS__/xadmin.css">
        <script src="__HOME_JS__/echarts.min.js"></script>
        <script src="__HOME_LIB__/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="__HOME_JS__/xadmin.js"></script>
        <!--[if lt IE 9]>
          <script src="__HOME_JS__/html5.min.js"></script>
          <script src="__HOME_JS__/respond.min.js"></script>
        <![endif]-->
    </head>
    
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">后台首页</a>
                <a href="">检修设备列表</a>
                <a>
                    <cite>设备安检记录</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">

                <div class="layui-col-md12">

                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <form class="layui-form layui-col-space5">

                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" name="device_serial"  placeholder="请输入设备编号" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                                </div>
                            </form>
                        </div>
                        <div class="layui-card-body ">
                            <table class="layui-table layui-form">
                                <thead>
                                    <tr>
                                        <th>设备编号</th>
                                        <th>设备型号</th>
                                        <th>状态</th>
                                        <th>操作员</th>
                                        <th>检修时间</th>
                                        <th>操作</th></tr>
                                </thead>
                                <tbody>
                                {volist name='row' id='vo'}
                                    <tr>
                                        <td>{$vo.device_serial}</td>
                                        <td>{$vo.device_model}</td>
                                        <td>{$vo.status_text}</td>
                                        <td>{$vo.operator_name}</td>
                                        <td>{$vo.check_time|date='Y-m-d'}</td>
                                        <td>
                                            {if $vo.status == 1}
                                            <a title="开始安检"  onclick="finish_check(this,{$vo.id})" href="javascript:;"><i class="layui-icon">完成安检</i></a>
                                            &nbsp;&nbsp;&nbsp;
                                            <a title="开始安检"  onclick="cancel_check(this,{$vo.id})" href="javascript:;"><i class="layui-icon">取消安检</i></a>
                                            {/if}
                                        </td>
                                    </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                        <div class="layui-card-body ">
                            <div class="page">
                                {:$pages}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    <script>layui.use(['laydate', 'form'],
        function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });
        });


        /*完成安全检查*/
        function finish_check(obj, id) {
            xadmin.open('添加用户',"{:url('index/securitycheck/finishcheck')}?id=" + id);
        }

        /*完成安全检查*/
        function cancel_check(obj, id) {
            layer.confirm('确定取消安检吗？',
                function () {
                    $.ajax({
                        url: "{:url('index/securitycheck/cancelcheck')}",
                        type: "POST",
                        sync: false,
                        data: {
                            ids: id
                        },
                        success: function (ret) {
                            if (ret.code === 0) {
                                $(obj).parents("tr").remove();
                                layer.msg(ret.msg, {
                                    icon: 1,
                                    time: 1500
                                });
                            } else {
                                layer.msg(ret.msg, {
                                    icon: 0,
                                    time: 2000
                                });
                            }
                        }
                    })
                }
            );
        }
</script>

</html>